#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>

int main() {
    int n = 0, m = 0;
    scanf("%d%d", &n, &m);
    char arr[n + 1];
    scanf("%s", arr);
    int l = 0, r = 0;
    char a = 0, b = 0;
    for (int i = 0; i < m; i++)
    {
        scanf(" %d%d", &l, &r);
        scanf(" %c%*c%c", &a, &b);
        for (int j = l - 1; j <= r - 1; j++)
        {
            if (arr[j] == a)
                arr[j] = b;
        }
    }
    printf("%s", arr);

    return 0;
}